<template>
	<view class="detail">
		<view class="order-lists" v-if="order.order_id">
			<view class="order-list">
				<view class="order-list-left">
					<image :src="order.detail.goods_img" mode="widthFix"></image>
				</view>
				<view class="order-list-right">
					<text class="title fex2">{{order.detail.goods_name}}</text>
					<view class="order-ta">
						<text>{{order.detail.goods_cate_name}}</text>
						<text>x {{order.detail.goods_ta}}</text>
					</view>
					<!-- -1未知,1待付款,2已付款,21处理中,3已发货,31配送中,32已拒签,4已收货,
					41结算中,5已结算,6失效,7已完成,8维权中,81维权成功,82维权失败,9退款,10退货,11系统锁定-->
					<view class="order-status">
						<view class="payment">
							<text>实付款:</text>
							<text>{{order.orders_price}}</text>
						</view>
						<text class="status" v-if="order.detail.dm_order_status == '-1'">未知</text>
						<text class="status" v-if="order.detail.dm_order_status == 1">待付款</text>
						<text class="status" v-if="order.detail.dm_order_status == 2">已付款</text>
						<text class="status" v-if="order.detail.dm_order_status == 21">处理中</text>
						<text class="status" v-if="order.detail.dm_order_status == 3">已发货</text>
						<text class="status" v-if="order.detail.dm_order_status == 31">配送中</text>
						<text class="status" v-if="order.detail.dm_order_status == 32">已拒签</text>
						<text class="status" v-if="order.detail.dm_order_status == 4">已收货</text>
						<text class="status" v-if="order.detail.dm_order_status == 41">结算中</text>
						<text class="status" v-if="order.detail.dm_order_status == 5">已结算</text>
						<text class="status" v-if="order.detail.dm_order_status == 6">失效</text>
						<text class="status" v-if="order.detail.dm_order_status == 7">已完成</text>
						<text class="status" v-if="order.detail.dm_order_status == 8">维权中</text>
						<text class="status" v-if="order.detail.dm_order_status == 81">维权成功</text>
						<text class="status" v-if="order.detail.dm_order_status == 82">维权失败</text>
						<text class="status" v-if="order.detail.dm_order_status == 9">退款,</text>
						<text class="status" v-if="order.detail.dm_order_status == 10">退货</text>
						<text class="status" v-if="order.detail.dm_order_status == 11">系统锁定</text>
					</view>
				</view>
			</view>
		</view>
		<view class="lists">
			<view class="list">
				<text>店铺名称</text>
				<text v-if="order.detail.shop_title">{{order.detail.shop_title}}</text>
			</view>
			<view class="list">
				<text>产品数量</text>
				<text>x {{order.detail.goods_ta}}</text>
			</view>
			<view class="list">
				<text>订单金额</text>
				<text class="price">{{order.orders_price}}</text>
			</view>
			<view class="list">
				<text>订单返利</text>
				<text>{{commissionAmount(order.siter_commission) || '0'}}sg</text>
			</view>
			<view class="list">
				<text>订单时间</text>
				<text>{{order.order_time}}</text>
			</view>
			<view class="list">
				<text>订单编号</text>
				<view class="right">
					<text>{{order.order_sn}}</text>
					<text class="copy" @click="copy(order.order_sn)">复制</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {selectOrder} from "@/api/duomai.js"
	export default{
		naem:"detail",
		data(){
			return{
				order:{
					siter_commission:'0',
					detail:{
						shop_title:""
					}
				}
			}
		},
		async onLoad(option) {
			if(option.id){
				let res = await selectOrder({id:option.id})
				if(res.code === 1){
					if(res.data.detail){
						let detail = JSON.parse(res.data.detail);
						if(detail.data&&detail.data.details.length){
							res.data.detail = detail.data.details[0]
							let img = res.data.detail.goods_img;
							if(img.indexOf("http") == -1 && 
							img.indexOf("https")){
								res.data.detail.goods_img = "http:"+res.data.detail.goods_img;
							}
						}
					}
					this.order = res.data;
				}
			}else{
				this.$msg("程序出错")
				setTimeout(()=>{
					uni.navigateBack()
				},2000)
			}
		},
		onNavigationBarButtonTap(e) {
			uni.navigateTo({
				url:'/pages/users/tborder/retrieve/retrieve'
			})
		},
		methods:{
			commissionAmount(val) {
				val = Math.ceil(Number(val.replace(/,/g, ''))*20);
				return val;
			},
			copy(val){
				uni.setClipboardData({
					data:val
				})
			},
		}
	}
</script>

<style lang="less" scoped src="./detail.less">
</style>
